﻿namespace Probel.NDoctor.Statistics.UnitTests.InMemory
{
    using System;
    using System.Collections.Generic;

    using Probel.NDoctor.Statistics.Domain;
    using Probel.NDoctor.Statistics.UnitTests.Helpers;
    using Probel.NDoctor.Statistics.RepositoriesImpl;

    public class MemoryRepositoryFiller
    {
        public static void Fill(MemoryRepository @this)
        {
            var apps = new List<Application>();
            var stat = new List<StatisticEntry>();

            for (int i = 0; i < 6; i++)
            {
                var date = Data.Today.AddDays(-10 - i);
                apps.Add(new Application()
                {
                    LastUpdate = date,
                    InstallationDate = date,
                    ApplicationKey = (i == 0) ? Data.AppKey : Guid.NewGuid(),
                    Version = "1.2.3.4"
                });
            }
            for (int i = 0; i < 10; i++)
            {
                stat.Add(new StatisticEntry()
                {
                    ExecutionTime = 10,
                    Threshold = 5,
                    IsPossibleBottleneck = (i % 2 == 0),
                    MethodName = Data.RandomString,
                    TargetTypeName = Data.RandomString,
                    TimeStamp = Data.Today
                });
            }
            foreach (var app in apps)
            {
                @this.Insert(app);
            }
            @this.Insert(stat);
        }
    }
}